<template>
  <el-dialog
    title="设置"
    :visible.sync="$attrs.visableIf"
    @close="handleCloseDialog"
    width="640px"
    append-to-body
    class="borderb_dia"
  >
    <el-form
      ref="form"
      :model="form"
      :rules="rules"
      size="small"
      label-width="130px"
      label-position="top"
    >
      <div class="line_h_22 mb-5">企微号白名单：</div>
      <div class="line_h_22 mb-24 c_666">ID下登录过的所有企业，下属企微号不会触发自动踢人</div>

      <el-form-item label="网址白名单：" prop="checked">
        <div class="line_h_22">1、若群成员发送的链接在网址白名单中，不会被踢；</div>
        <div class="line_h_22 mb-12">2、输入网址，一行一个，无需包含“http://””https://”。</div>
        <el-input v-model="form.web" type="textarea" rows="3" placeholder="一行一个网址"/>
      </el-form-item>

      <el-form-item label="小程序白名单：" prop="checked">
        <div class="line_h_22">1、若群成员发送的小程序在小程序白名单中，不会被踢</div>
        <div class="line_h_22 mb-12">2、需输入小程序APPID或者小程序名称，一行一个</div>
        <el-input v-model="form.web" type="textarea" rows="3" placeholder="一行一个小程序AppId"/>
      </el-form-item>

      <el-form-item label="视频号白名单：" prop="checked">
        <div class="line_h_22">1、若群成员发送的视频号在视频号白名单中，不会被踢</div>
        <div class="line_h_22 mb-12">2、需输入视频号名称，一行一个</div>
        <el-input v-model="form.web" type="textarea" rows="3" placeholder="一行一个视频号名称"/>
      </el-form-item>

      <el-form-item label="白名单企业设置：" prop="checked">
        <div class="line_h_22">1、精准匹配企微号“@”后的企业名称，入群和发言时检测</div>
        <div class="line_h_22 mb-12">2、ID下登录的企业自动默认为白名单企业</div>
        <el-input v-model="form.web" type="textarea" rows="3" placeholder="一行一个企业，最多50个企业"/>
      </el-form-item>
    </el-form>
    <div slot="footer">
      <el-button size="small" @click="handleCloseDialog">取消</el-button>
      <el-button size="small" type="primary" @click="submitForm">确认</el-button>
    </div>
  </el-dialog>
</template>

<script>
// import { validPhone, validPassword } from "@/utils/validate";
// import { editInfo } from "@/api/advmaster";
export default {
  data() {
    return {
      form: {
        name: "",
        min: 5,
        max: 10,
      },
      // 表单校验
      rules: {
        name: [{ required: true, message: "请输入用户名", trigger: "blur" }],
        email: [
          {
            required: true,
            type: "email",
            message: "请输入正确的邮箱地址",
            trigger: "blur",
          },
        ],
        password: [],
        status: [{ required: true, message: "请选择状态", trigger: "change" }],
      },
    };
  },
  props: {
    rowitem: {
      default: null,
    },
  },
  created() {},
  methods: {
    handleCloseDialog() {
      this.$emit("update:visableIf", false);
    },

    onBlur(type) {
      // 使用正则表达式匹配正整数
      const regex = /^[1-9]\d*$/;
      // 如果输入的值不是正整数，则将其设置为上一个有效值
      if (!regex.test(this.form[type])) {
        if (type == "min") {
          this.form.min = 5;
        } else {
          this.form.max = 10;
        }
      } else {
        if (this.form[type] > 999) {
          this.form[type] = 999;
        }
      }
    },

    handleDefault() {
      this.form.min = 5;
      this.form.max = 10;
    },

    submitForm: function () {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != undefined) {
            // editInfo(this.form).then(() => {
            //   this.$modal.msgSuccess('修改成功')
            //   this.handleCloseDialog();
            //   this.$emit('getList');
            // })
          }
        }
      });
    },
  },
};
</script>

<style scoped lang="scss">
.delay {
  background: #f0f0f0;
  border: 1px solid #e9e9e9;
  padding: 7px 14px;
  margin-bottom: 8px;
}
.divi {
  display: inline-block;
  margin: 0 6px;
}
.el-form {
    ::v-deep .el-form-item__label{
        padding: 0;
    }
}
</style>
